<template>
  <el-header>
    <div class="l-content">
      <!-- 图标的展示 -->
      <el-button size="small">
        <el-icon :size="20" plain @click="handleCollapse">
          <Menu />
        </el-icon>
      </el-button>
      
    </div>

    <div class="r-content">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img class="user" :src="getImgSrc()" alt="" />
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item><el-icon>
                <Avatar />
              </el-icon>个人中心</el-dropdown-item>
            <el-dropdown-item><el-icon>
                <Lock />
              </el-icon>密码修改</el-dropdown-item>
            <el-dropdown-item style="color: red;"><el-icon>
                <CircleCloseFilled />
              </el-icon>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </el-header>
</template>

<script>
import { computed, defineComponent } from "vue-demi";
import { useStore } from 'vuex'
export default {
  setup() {
    let store = useStore();
    // const imgSrc = require('../assets/images/user.png')
    const getImgSrc = () => {
      return new URL("../assets/images/user.png", import.meta.url).href;
    };

    let handleCollapse = () => {
      //调用vuex中的mutations
      store.commit("updateIsCollapse");
    };
    //计算属性 computed
    const current = computed(() => {
      return store.state.currentMenu;
    });
    return {
      // imgSrc,
      getImgSrc,
      handleCollapse,
      current,
    };

  }
}



</script>


<style scoped>
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #558aa5;
}

.r-content {
  .user {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}

.l-content {
  display: flex;
  align-items: center;

  .el-button {
    margin-right: 20px;
  }

  h3 {
    color: #fff;
  }
}

/deep/.bread span {
  color: #558aa5 !important;
  cursor: pointer !important;
}
/deep/.el-menu {
  margin-top: 35%;
}
</style>